// 搜索js
var $scope = null;
$(function() {
	var appElement = document.querySelector('[ng-controller=main]');
	$scope = angular.element(appElement).scope();
	  initialPage($scope);
});
// 初始化值
function initialPage($scope) {
	
	
}
var mainApp = angular.module("mainApp", []);
mainApp.controller('main', function($scope) {
	$scope.search={};
	$scope.methods = {
		getSearch : function() {
			var startTime = new Date(); 
			if($scope.search.name){
				$.ajax({
				    url:$.shysUrlPrefix+'/website/getSearch?searchStr='+$scope.search.name,
				    type:'get',
				    dataType:'JSON',
					async:true,  //同步方式发起请求
					  beforeSend: function () {
					        $(".loading").show();
					    },
				    success:function (data) {
						var endTime = new Date(); 
						$scope.timeDiffInDays = Math.floor((endTime - startTime) / (1000 * 60 * 60 * 24));
						if (data.data&&data.data.length>0 ) {
							$scope.searchData=data.data
							$scope.datalength=data.data.length
							$(".widget-kong").hide()
							$(".search-content").show()
							$scope.$apply();
						} else {
						   $(".widget-kong").show()
						   $(".search-content").hide()
						}
						
				    },
					 complete: function () {
					        $(".loading").hide();
					    },
				
				})
			}else{
				
			}
			
		},
		// 点击详情
		labelDetailClick: function (label) {
		 console.log(label.itemId)
		 if(label.type=='dynamic'){
			  window.location.href="dongtai-detail.html?dynamicId="+label.itemId
		 }else if(label.type=='policy'){
			 window.location.href="policy.html?policyId="+label.itemId
		 }else if(label.type=='bridge'){
			 window.location.href="account-detail.html?checkListId="+label.itemId
		 }else if(label.type=='video'){
			 window.location.href="video-detail.html?videoId="+label.itemId
		 }else if(label.type=='model'){
			  window.location.href="model-detail.html?modelId="+label.itemId
		 }else if(label.type=='image'){
			  window.location.href="resource-Detail.html?imageItemId="+label.itemId
		 }
		
		},
		
		
	};
});











